var t = require("../../services/api.js"),
  e = require("../../utils/util.js"),
  url = require("../../services/baseURL.js");

getApp();

Page({
  data: {
    info: {},
    status: -1,
    isIphoneX: /iPhone X/.test(wx.getSystemInfoSync().model)
  },
  onLoad: function(t) {},
  getDetail: function(a) {
    var n = this,
      i = (0, e.getLocation)();
    // i || (i = {
    //   name: "成都",
    //   latitude: "30.657446",
    //   longitude: "104.065746"
    // }), (0, t.getTaskDetail)({
    //   id: a,
    //   lng: i.longitude,
    //   lat: i.latitude
    // }).then(function(t) {
    //   if (200 === t.data.code) {
    //     var a = t.data.data;
    //     n.setData({
    //       info: a,
    //       status: (0, e.getOrderStatus)(a)
    //     });
    //   } else wx.showModal({
    //     title: "提示",
    //     content: "无效商品",
    //     showCancel: !1,
    //     success: function() {
    //       wx.switchTab({
    //         url: "/pages/index/index"
    //       });
    //     }
    //   });
    // });
    wx.request({
      url: "".concat(url.baseURL, "/xcxapi/goodsdatail"),
      data:{
        id:a,
        lng: "104.065746",
        lat: "30.657446"
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(e) {
        if (200 === e.data.status) {
          var a = e.data.data;
          n.setData({
            info: a,
          });
        }else wx.showModal({
          title: '提示',
          content: '无效商品',
          showCancel: !1,
          success: function(){
            wx.switchTab({
              url: "/pages/index/index"
            });
          }
        });
      },
      fail(res) {
        console.log("请求错误！");
      }
    });

  },
  giveUpTask: function() {
    var e = this;
    wx.showModal({
      title: "提示",
      content: "确定放弃任务吗？",
      confirmText: "放弃",
      cancelText: "再考虑",
      success: function(a) {
        a.confirm && (0, t.taskQuit)({
          t_m_id: e.data.info.stage.tmi_id
        }).then(function(t) {
          200 === t.data.code ? wx.showToast({
            title: "操作成功",
            mask: !0
          }) : wx.showModal({
            title: "提示",
            content: t.data.message,
            showCancel: !1
          }), e.getDetail();
        });
      }
    });
  },
  payHandle: function() {
    var a = this;
    if ((0, e.getAuth)()) {
      var n = this.data.status;
      if (0 === n || 2 === n) return void wx.navigateTo({
        url: "/pages/form/index?id=".concat(this.data.info.id)
      });
      if (1 === n || 3 === n) return wx.showModal({
        title: "提示",
        content: this.data.info.stage.stage,
        showCancel: !1
      }), !1;
      if (4 === n) return wx.showModal({
        title: this.data.info.stage.stage,
        content: this.data.info.stage.msg,
        showCancel: !1
      }), !1;
      wx.showModal({
        title: "提示",
        content: "请在抢单后30分钟内上传订单图，否则视为自动放弃，确认抢单？",
        success: function(e) {
          if (e.confirm) {
            var n = a.data.info.id;
            (0, t.grabTask)({
              task_id: n
            }).then(function(t) {
              200 === t.data.code ? (wx.showToast({
                title: "抢单成功",
                mask: !0
              }), a.getDetail(n), wx.setStorageSync("t_m_id", t.data.data.t_m_id), wx.canIUse("requestSubscribeMessage") && wx.requestSubscribeMessage({
                tmplIds: ["yfb4cxICJJwJGUK0IXayBiXHJzVbVzhN30kYaGn4gPg", "TLVtLWQfcY6-ryf38baunx31n5w6YT6qJMx7Tbuln8g", "AB9nIjOGH2BrAeFGixwaWJd_hEGXDma57VrQZw8rzbw"]
              })) : wx.showModal({
                title: "提示",
                content: t.data.message,
                showCancel: !1
              });
            });
          }
        }
      });
    } else wx.navigateTo({
      url: "/pages/login/index"
    });
  },
  onReady: function() {},
  onShow: function() {
    var t = this.options;
    t.id ? this.getDetail(t.id) : wx.showModal({
      title: "提示",
      content: "无效商品2",
      showCancel: !1,
      success: function() {
        wx.switchTab({
          url: "/pages/index/index"
        });
      }
    });
  },
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  copywx: function() {
    wx.setClipboardData({
      data: "13271860714",
      success: function(t) {
        wx.showModal({
          title: "提示",
          content: "已复制客服微信",
          showCancel: !1
        });
      }
    });
  },
  onReachBottom: function() {},
  onShareAppMessage: function() {}
});